#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <fstream>
#include <iostream>
#include <unistd.h>

class test_pointer {
private:
    friend boost::serialization::access;
    int a;
    int b;
    template <class Archive>
    void serialize(Archive& ar, const unsigned int version)
    {
	ar& a;
	ar& b;
    }

public:
    test_pointer(){}
    test_pointer(int na, int nb)
	: a(na)
	, b(nb)
    {
    }
    void print()
    {
	std::cout << a << " " << b << std::endl;
    }
};

int main(int argc, char* argv[])
{
    test_pointer A(1, 12);
    std::ofstream ofs;
    ofs.open("./textserail",std::ios_base::out|std::ios_base::trunc);
    boost::archive::text_oarchive oa(ofs);

    oa << A;

    ofs<<std::flush;

    std::ifstream ifs;
    ifs.open("./textserail",std::ios_base::in);
    boost::archive::text_iarchive ia(ifs);
    //sleep(5);
    test_pointer B;
    ia >> B;
    B.print();
    return 0;
}
